local io = require("io")
local http = require("socket.http")
local ltn12 = require("ltn12")

_url = "http://wow-mostwanted.googlecode.com/svn/trunk/WantedList.lua"

local r, c = socket.http.request {
    url = _url,
    sink = ltn12.sink.file(io.open("update.tmp","w")),
    headers = { ["User-Agent"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)" }
}

if(c==200) then
	os.remove("WantedList.lua."..os.date("%Y%m%d%H%M"))
	os.rename("WantedList.lua", "WantedList.lua."..os.date("%Y%m%d%H%M"))
	os.rename("update.tmp", "WantedList.lua")
	print("WantedList.lua updated.")
else
	print("Update from ".._url.." failed.")
end